package interview.sync.array;/*

 */

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @ClassName CyclicBarrierDemo
 * @Author Final
 * @Project DataStructures
 */
public class CyclicBarrierDemo {

    private static final  int NUMBER=7;

    public static void main(String[] args) {

        CyclicBarrier cyclicBarrier=new CyclicBarrier(NUMBER,()->{
            System.out.println("111");
        });

        for (int i=1;i<=7;i++){
            new Thread(()->{
                System.out.println("22222222222222");

                try {
                    cyclicBarrier.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            },"aaa").start();
        }
    }
}
